import DelButton from '../../../components/delbutton';
import { IData } from '../../api/admin/role/query.api';
import Edit from './edit';
import api from '../../../atoms/api';
import Table from '../../../components/table';
import Menus from './menus';

export default function List({
	data,
	menus
}: {
	data: IData[];
	menus: ITbfdmenu[];
}) {
	return <>
		<Table
			idfieldname='roleid'
			render={(record) => {
				const roleid = record.roleid;
				return <>
					<Menus role={record} menus={menus} />
					<Edit data={record} />
					<DelButton query={{
						roleid
					}} dlgtitle='确认删除该角色?删除后，相应的权限也会一并删除' api={api['/api/admin/role/del']} />
				</>;
			}}
			data={data}
		>
			<Table.Column<IData> title='名称' dataIndex='name' align='left' />
			<Table.Column<IData> title='描述' dataIndex='description' align='left' />
		</Table>
	</>;
}
